﻿@page
@using Snow.Hcm.Localization;
@using Microsoft.AspNetCore.Authorization
@using Microsoft.Extensions.Localization
@using Snow.Hcm.Permissions
@using Snow.Hcm.Web.Pages.Employees
@inject IStringLocalizer<HcmResource> L
@model EditModel
@using Snow.Hcm.Web.Menus
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Uppy
@inject IAuthorizationService Authorization
@inject IPageLayout PageLayout
@{
    PageLayout.Content.Title = L["Employees"].Value;
    PageLayout.Content.BreadCrumb.Add(L["Menu:Employees"].Value);
    PageLayout.Content.MenuItemName = HcmMenus.Employees;
}
@section styles {
    <abp-style-bundle name="@typeof(EditModel).FullName">
        <abp-style src="/libs/select2-bootstrap4-theme/select2-bootstrap4.min.css" />
        <abp-style src="/libs/select2/css/select2.min.css" rel="stylesheet" />
        <abp-style src="/libs/daterangepicker/daterangepicker.css" />
    </abp-style-bundle>
}
@section scripts
{
    <abp-script-bundle name="@typeof(EditModel).FullName">
        <abp-script src="/libs/moment/min/moment.min.js" />
        <abp-script src="/libs/daterangepicker/daterangepicker.js" />
        <abp-script src="/js/bootstrapNavLink.js" />
        <abp-script type="typeof(UppyScriptContributor)" />
        <abp-script src="/Pages/Employees/Edit.js" />
    </abp-script-bundle>
}
<abp-card id="EmployeesWrapper">
    <abp-card-body>
        <ul class="nav nav-tabs" id="myTab" role="tablist">
            <li class="nav-item" role="presentation">
                <a class="nav-link active" id="basic-tab" data-toggle="tab" href="#basic" role="tab" aria-controls="basic" aria-selected="true">@L["BasicInfo"]</a>
            </li>
            @if (await Authorization.IsGrantedAsync(HcmPermissions.EmergencyContacts.Default))
            {
                <li class="nav-item" role="presentation">
                    <a class="nav-link" id="emergencyContact-tab" data-toggle="tab" href="#emergencyContact" role="tab" aria-controls="emergencyContact" aria-selected="false">@L["EmergencyContact"]</a>
                </li>
            }
            @if (await Authorization.IsGrantedAsync(HcmPermissions.WorkExperiences.Default))
            {
                <li class="nav-item" role="presentation">
                    <a class="nav-link" id="workExperience-tab" data-toggle="tab" href="#workExperience" role="tab" aria-controls="workExperience" aria-selected="false">@L["WorkExperience"]</a>
                </li>
            }
            @if (await Authorization.IsGrantedAsync(HcmPermissions.EducationExperiences.Default))
            {
                <li class="nav-item" role="presentation">
                    <a class="nav-link" id="educationExperience-tab" data-toggle="tab" href="#educationExperience" role="tab" aria-controls="educationExperience" aria-selected="false">@L["EducationExperience"]</a>
                </li>
            }
        </ul>
        <div class="tab-content" id="myTabContent">
            <div class="tab-pane fade show active" id="basic" role="tabpanel" aria-labelledby="basic-tab">
                <form method="post" action="@Url.Page("/Employees/Edit")" id="form-employee-edit">
                    <abp-input asp-for="Employee.Id" />
                    <abp-input asp-for="Employee.CoverImageMediaId" />
                    <div class="form-group">
                        @if (Model.Employee.CoverImageMediaId != null)
                        {
                            <img height="120" src="/api/hcm/media/@Model.Employee.CoverImageMediaId" />
                            <br />
                        }
                        <label>@L["CoverImage"]</label>
                        <input type="file" id="CoverImage" class="form-control" />
                    </div>
                    <abp-input asp-for="Employee.Name" />
                    <abp-input asp-for="Employee.PhoneNumber" type="number" />
                    <abp-input asp-for="Employee.IdCardNumber" />
                    <div class="form-row">
                        <div class="form-group col-md-9">
                            <label asp-for="Employee.Birthday" class="control-label"></label>
                            <input asp-for="Employee.Birthday" class="form-control" />
                            <span asp-validation-for="Employee.Birthday" class="text-danger"></span>
                        </div>
                        <div class="form-group col-md-3">
                            <label asp-for="Employee.Calendar" class="control-label"></label>
                            <select asp-for="Employee.Calendar" class="form-control custom-select" asp-items="Model.Calendars">
                            </select>
                        </div>
                    </div>
                    <abp-select asp-for="Employee.Gender" />
                    <div class="form-row">
                        <div class="form-group col-md-6">
                            <label asp-for="Employee.BankCardNumber" class="control-label"></label>
                            <input asp-for="Employee.BankCardNumber" class="form-control" />
                            <span asp-validation-for="Employee.BankCardNumber" class="text-danger"></span>
                        </div>
                        <div class="form-group col-md-6">
                            <label asp-for="Employee.BankOfDeposit" class="control-label"></label>
                            <input asp-for="Employee.BankOfDeposit" class="form-control" />
                            <span asp-validation-for="Employee.BankOfDeposit" class="text-danger"></span>
                        </div>
                    </div>
                    <abp-select asp-for="Employee.MaritalStatus" />
                    <abp-select asp-for="Employee.PoliticalStatus" />
                    <abp-select asp-for="Employee.Zodiac" />
                    <abp-select asp-for="Employee.Constellation" />
                    <abp-select asp-for="Employee.BloodType" />
                    @await Component.InvokeAsync("Region", new
                    {
                        parentId = 100000,
                        provinceId = Model.Employee.ProvinceId,
                        cityId = Model.Employee.CityId,
                        areaId = Model.Employee.AreaId
                    })
                    <input asp-for="Employee.ProvinceId" />
                    <input asp-for="Employee.CityId" />
                    <input asp-for="Employee.AreaId" />
                    <abp-input asp-for="Employee.Address" />

                    <button type="button" class="btn btn-primary" id="button-employee-edit" data-busy-text="@L["SavingWithThreeDot"]">
                        <i class="fa-check fa"></i>
                        <span>@L["Save"]</span>
                    </button>
                </form>
            </div>
            @if (await Authorization.IsGrantedAsync(HcmPermissions.EmergencyContacts.Default))
            {
                <div class="tab-pane fade" id="emergencyContact" role="tabpanel" aria-labelledby="emergencyContact-tab">
                    @if (await Authorization.IsGrantedAsync(HcmPermissions.EmergencyContacts.Create))
                    {
                        <abp-button name="CreateEmergencyContact"
                                    text="@L["NewEmergencyContact"].Value"
                                    icon="plus"
                                    button-type="Primary" />
                    }
                    <abp-table striped-rows="true"></abp-table>
                </div>
            }
            @if (await Authorization.IsGrantedAsync(HcmPermissions.WorkExperiences.Default))
            {
                <div class="tab-pane fade" id="workExperience" role="tabpanel" aria-labelledby="workExperience-tab">
                    @if (await Authorization.IsGrantedAsync(HcmPermissions.WorkExperiences.Create))
                    {
                        <abp-button name="CreateWorkExperience"
                                    text="@L["NewWorkExperience"].Value"
                                    icon="plus"
                                    button-type="Primary" />
                    }
                    <abp-table striped-rows="true"></abp-table>
                </div>
            }
            @if (await Authorization.IsGrantedAsync(HcmPermissions.EducationExperiences.Default))
            {
                <div class="tab-pane fade" id="educationExperience" role="tabpanel" aria-labelledby="educationExperience-tab">
                    @if (await Authorization.IsGrantedAsync(HcmPermissions.EducationExperiences.Create))
                    {
                        <abp-button name="CreateEducationExperience"
                                    text="@L["NewEducationExperience"].Value"
                                    icon="plus"
                                    button-type="Primary" />
                    }
                    <abp-table striped-rows="true"></abp-table>
                </div>
            }
        </div>
    </abp-card-body>
</abp-card>
